import React from 'react'
import { useParams, useLocation, useSearchParams } from 'react-router-dom'
// useParams 用来接收路由参数
// useLocation 拿到一个location对象. location.state可以获取state数据
// useSearchParams 可以获取查询字符串,也可以修改当前浏览器地址栏的查询字符串
export default function Login() {
  const params = useParams()
  console.log('路由参数: ', params)

  const location = useLocation()
  console.log('location', location)

  const [query, setQuery] = useSearchParams()
  console.log(query.get('car'))
  console.log(query.get('xxsxs'))
  return (
    <div>
      <h1>Login</h1>
      <button
        onClick={() => {
          setQuery('a=1&b=2')
        }}
      >
        修改查询字符串
      </button>
    </div>
  )
}
